import axios from 'axios';
import qs from 'querystring';

axios.defaults.baseURL = 'http://alumni2023.twtstudio.com';
export function service(config) {
    const instance = axios.create({
        baseURL: config.baseURL,
        timeout: 5000,
    })
    instance.interceptors.request.use((config) => {
        //请求时加loading句
        //if(config.method == 'POST') config.data = qs.stringify(config.data);
        config.data = qs.stringify(config.data);
        return config;
    })
/*     instance.interceptors.response.use((res) => {
        //取消loading句
        if(res.status === 200) {
            const { data } = response;
            console.log(res);
            if(data.code === 200) return data.data;
            else {
                //ElMessage提示
                return;
            } 
        } else if(response.status === 500) {
            return;
        } 
    }, err => {
        //取消loading
        return Promise.reject(err);
    }) */
    return instance(config);
}
